<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "graduation_eligible_student".
 *
 * @property int $BYZGSHID 毕业资格审核ID
 * @property int $XSID 学生ID
 * @property string $XSXM 学生姓名
 * @property string $XB 性别
 * @property string $SFZHM 身份证号码
 * @property string $GGJCK 公共基础课
 * @property string $ZYJNK 专业技能课
 * @property string $CX 操行
 * @property string $BYSX 毕业实习
 * @property string $BYZBH 毕业证编号
 * @property string $SHZT 审核状态
 *
 * @property GraduationEligibleAudit $bYZGSH
 * @property Student $xS
 */
class GraduationEligibleStudent extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'graduation_eligible_student';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['BYZGSHID', 'XSID', 'XSXM', 'XB', 'SFZHM', 'GGJCK', 'ZYJNK', 'CX', 'BYSX', 'BYZBH', 'SHZT'], 'required'],
            [['BYZGSHID', 'XSID'], 'integer'],
            [['XB'], 'string'],
            [['XSXM'], 'string', 'max' => 50],
            [['SFZHM', 'BYZBH'], 'string', 'max' => 20],
            [['GGJCK', 'ZYJNK', 'CX', 'BYSX'], 'string', 'max' => 8],
            [['SHZT'], 'string', 'max' => 10],
            [['BYZGSHID', 'XSID'], 'unique', 'targetAttribute' => ['BYZGSHID', 'XSID']],
            [['BYZGSHID'], 'exist', 'skipOnError' => true, 'targetClass' => GraduationEligibleAudit::className(), 'targetAttribute' => ['BYZGSHID' => 'ID']],
            [['XSID'], 'exist', 'skipOnError' => true, 'targetClass' => Student::className(), 'targetAttribute' => ['XSID' => 'ID']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'BYZGSHID' => '毕业资格审核ID',
            'XSID' => '学生ID',
            'XSXM' => '学生姓名',
            'XB' => '性别',
            'SFZHM' => '身份证号码',
            'GGJCK' => '公共基础课',
            'ZYJNK' => '专业技能课',
            'CX' => '操行',
            'BYSX' => '毕业实习',
            'BYZBH' => '毕业证编号',
            'SHZT' => '审核状态',
        ];
    }

    /**
     * Gets query for [[BYZGSH]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getBYZGSH()
    {
        return $this->hasOne(GraduationEligibleAudit::className(), ['ID' => 'BYZGSHID'])->inverseOf('graduationEligibleStudents');
    }

    /**
     * Gets query for [[XS]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getXS()
    {
        return $this->hasOne(Student::className(), ['ID' => 'XSID'])->inverseOf('graduationEligibleStudents');
    }
}
